package com.eastcom.providor.dao.impl;

import java.util.List;

import com.eastcom.bm.atom.Atom_ActionRule;
import com.eastcom.providor.dao.BaseDao;
import com.eastcom.providor.dao.IActionRuleDao;

public class ActionRuleDao extends BaseDao implements IActionRuleDao {

	public Atom_ActionRule getActionRuleByDataSetId(String datasetId)throws Exception {
		try{
			List<Atom_ActionRule> actionRules=this.getObjects("from Atom_ActionRule where datasetId='"+datasetId+"'");
			return actionRules==null||actionRules.isEmpty()?null:actionRules.get(0);
		}
		catch(Exception e){
			throw e;
		}
	}

	public List<Atom_ActionRule> getAllActionRule() throws Exception {
		try{
			return this.getObjects("from Atom_ActionRule");
		}
		catch(Exception e){
			throw e;
		}
	}

	public void deleteByDataSetId(String datasetId) throws Exception {
		try{
		    this.deleteObjects("delete Atom_ActionRule where datasetId = ?", new String[]{datasetId});
		}
		catch(Exception e){
			throw e;
		}
	}

}
